﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DnDEngine.WebEngine;
using DbConnect;


namespace TestForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
           var p =  DnDEngine.DnDEngine.AddWebSite(tb_weburl.Text, "", tb_webName.Text);
           if (p)
           {
               lb_website.Text = "Ok";
           }
           else
           {
               lb_website.Text = "Fail";
           }

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (var item in DnDEngine.DnDEngine.LWebSites)
            {
                this.listBox1.Items.Add(item);
            }
            this.dataGridView1.DataSource = Logger.Log.GetInstance().ViewDbTrace();
            dataGridView1.Refresh();
        }

        private void bt_insRequest_Click(object sender, EventArgs e)
        {
            var p = DnDEngine.DnDEngine.AddRequest(tb_requrl.Text, tb_reqWebsite.Text);

            if (p)
            {
                lb_request.Text = "Ok";
            }
            else
            {
                lb_request.Text = "Fail";
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                Logger.Log.Close();
            }
            finally
            {
            }
            
        }
    }
}
